import UIKit
import Flutter
import GoogleMaps
//import UserNotifications

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
    override func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
//        UNUserNotificationCenter.current().delegate = self
//        UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) { granted, error in
//            guard granted else { return }
//        }
        GMSServices.provideAPIKey("AIzaSyBa_GhyESIeCilWrhzOi7pM0sSvkG6s7Kk")
        // Metal is the preferred renderer.
        GMSServices.setMetalRendererEnabled(true)
        GeneratedPluginRegistrant.register(with: self)
        return super.application(application, didFinishLaunchingWithOptions: launchOptions)
    }
    
//    override func applicationWillTerminate(_ application: UIApplication) {
//        NSLog("app exit")
//        // 退出通知
//        let content = UNMutableNotificationContent()
//        content.title = "通知标题"
//        content.body = "这是通知的内容"
//        //content.sound = UNNotificationSound.default
//
//        // 创建触发器
//        let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 1, repeats: false)
//
//        // 创建请求
//        let request = UNNotificationRequest(identifier: "myNotification", content: content, trigger: trigger)
//
//        // 将通知添加到中心
//        UNUserNotificationCenter.current().add(request) { error in
//            if let error = error {
//                print(error.localizedDescription)
//            }
//        }
//    }
}
